//力扣238. 除自身以外数组的乘积
class Solution {
    public int[] productExceptSelf(int[] nums) {
        int[] res=new int[nums.length];
        //res先存储前缀积
        for(int i=0;i<nums.length;i++){
            if(i==0){
                res[i]=1;
                continue;
            }
            res[i]=nums[i-1]*res[i-1];
        }
        //前缀积乘以后缀积
        int count=1;
        for(int i=nums.length-2;i>=0;i--){
            count*=nums[i+1];
            res[i]*=count;
        }
        return res;
    }
}

//力扣53. 最大子数组和
class Solution1 {
    public int maxSubArray(int[] nums) {
        int tmp=-1;
        int res=Integer.MIN_VALUE;
        for(int i=0;i<nums.length;i++){
            tmp=Math.max(nums[i],nums[i]+tmp);
            res=Math.max(tmp,res);
        }
        return res;
    }
}